class Share {
  final int id;
  final String description;
  final String picture;  // 保留原有字段，用于兼容性
  final List<String> pictures; // 新增字段，支持多张图片
  final String time;
  final int userId;

  Share({
    required this.id,
    required this.description,
    required this.picture,
    List<String>? pictures,
    required this.time,
    required this.userId,
  }) : this.pictures = pictures ?? [picture];

  // 从JSON转换为Share对象
  factory Share.fromJson(Map<String, dynamic> json) {
    return Share(
      id: json['id'],
      description: json['description'],
      picture: json['picture'],
      pictures: json['pictures'] != null 
          ? List<String>.from(json['pictures'])
          : [json['picture']],
      time: json['time'],
      userId: json['userId'],
    );
  }

  // 将Share对象转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'description': description,
      'picture': picture,
      'pictures': pictures,
      'time': time,
      'userId': userId,
    };
  }
} 